package com.xiaoshu.controller;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.plugins.Page;
import com.xiaoshu.api.result.AdvertiserResult;
import com.xiaoshu.bean.PagingParam;
import com.xiaoshu.bean.PagingResult;
import com.xiaoshu.bean.Response;
import com.xiaoshu.entity.Advertiser;
import com.xiaoshu.paging.Paging;
import com.xiaoshu.service.IAdvertiserService;

/**
 * 
 * @author Administrator
 * 
 */
@RestController
public class AdvertiserController {

	@Autowired
	private IAdvertiserService advertiserService;

	@RequestMapping(value = "/advertisers", method = RequestMethod.GET)
	public Response listAdvertiser(PagingParam pagingParam) {
		Page<Advertiser> page = new Page<Advertiser>();
		page.setCurrent(pagingParam.getPagingNumber());
		page.setSize(pagingParam.getPageSize());
		page = advertiserService.selectPage(page);

		Paging<Advertiser> advertiserResultPaging = new Paging<Advertiser>(
				page.getCurrent(), page.getSize(), page.getTotal(),
				page.getRecords());

		return new Response()
				.success(new PagingResult<>(advertiserResultPaging));
	}

}
